var SPICFG_DIR_PUBSITE_STYLES = '';

function startup( pubsite_styles )
{
    SPICFG_DIR_PUBSITE_STYLES = pubsite_styles;

    //-------------------------------------------------------------------------

    var startup_functions = new Array();

    $('.handler__startup_function').each(
    function()
    {
        var function_name = $(this).attr('function');

        if( jQuery.inArray( function_name, startup_functions ) == -1 )
        {
            startup_functions[ startup_functions.length ] = function_name;
        }
        return true;
    } );

    for( var lp=0; lp<startup_functions.length; lp++ )
    {
        eval( startup_functions[lp] );
    }

	catalogs_startup();
	content_params_startup();
	
    return true;
}

function catalogs_startup()
{
	$('.catalog-description-button-show').click(
		function()
		{
			$(this).hide();
			$(this).closest('.catalog-description-box').find('.catalog-description-button-hide').show();
			
			var imageNode = $(this).closest('.catalog-description-box').find('.catalog-description-img');
			
			imageNode.attr('small_img_link',   imageNode.attr('src'));
			imageNode.attr('small_img_width',  imageNode.attr('width'));
			
			imageNode.attr('src', imageNode.attr('large_img_link'));
			imageNode.animate( {'width': imageNode.attr('large_img_width')} );
			
			$(this).closest('.catalog-description-box').find('.catalog-description-full').slideToggle();
			$(this).closest('.catalog-description-box').find('.catalog-description-short').slideToggle();
			return true;
		}
	);
	
	$('.catalog-description-button-hide').click(
		function()
		{
			$(this).hide();
			$(this).closest('.catalog-description-box').find('.catalog-description-button-show').show();
			
			var imageNode = $(this).closest('.catalog-description-box').find('.catalog-description-img');
			
			imageNode.attr('large_img_link',   imageNode.attr('src'));
			imageNode.attr('large_img_width',  imageNode.attr('width'));
			
			imageNode.attr('src', imageNode.attr('small_img_link'));
			imageNode.animate( {"width": imageNode.attr('small_img_width')} );
			
			$(this).closest('.catalog-description-box').find('.catalog-description-full').slideToggle();
			$(this).closest('.catalog-description-box').find('.catalog-description-short').slideToggle();
			return true;
		}
	);
	
	return true; /* @todo: comment this */
	
	$('.cat-root, .cat-level-first').click(
		function()
		{
			var id = $(this).attr('subid');
			$('#cat'+id).slideToggle();
		}
	);
	
	return true;
}

function content_params_startup()
{
	$('.params-description-shower').mouseover(
		function()
		{
			var id = $(this).attr('descr_id');
			$('#param-description-'+id).show();
		}
	);
	
	$('.params-description-shower').mouseout(
		function()
		{
			var id = $(this).attr('descr_id');
			$('#param-description-'+id).hide();
		}
	);
	
	return true;
}